home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Mud 4.0 / prelang.y < prev    next >
Encoding:
Lex Description  |  1993-03-16  |  19.0 KB  |  684 lines  |  [TEXT/tefi]

  1. %{
  2. # line 3 "prelang.y"
  3. /* The above line is to give proper line number references. Please mail me
  4.  * if your compiler complains about it.
  5.  */
  6. /*
  7.  * This is the grammar definition of LPC. The token table is built
  8.  * automatically by make_func. The lang.y is constructed from this file,
  9.  * the generated token list and post_lang.y. The reason of this is that there
  10.  * is no #include-statment that yacc recognizes.
  11.  */
  12. #include <string.h>
  13. #include <stdio.h>
  14. #include <memory.h>
  15. #if defined(sun)
  16. #include <alloca.h>
  17. #endif
  18.  
  19. #include "lint.h"
  20. #include "interpret.h"
  21. #include "object.h"
  22. #include "exec.h"
  23. #include "config.h"
  24. #include "instrs.h"
  25. #include "incralloc.h"
  26. #include "switch.h"
  27. #include "rc.h"
  28.  
  29. #if defined(__GNUC__) && !defined(lint) && !defined(DEBUG)
  30. #define INLINE inline
  31. #else
  32. #define INLINE
  33. #endif
  34.  
  35. #define YYMAXDEPTH    600
  36.  
  37. /* NUMPAREAS areas are saved with the program code after compilation.
  38.  */
  39. #define A_PROGRAM        0
  40. #define A_FUNCTIONS        1
  41. #define A_STRINGS        2
  42. #define A_VARIABLES        3
  43. #define A_LINENUMBERS        4
  44. #define A_INHERITS        5
  45. #define A_ARGUMENT_TYPES    6
  46. #define A_ARGUMENT_INDEX    7
  47. #define NUMPAREAS        8
  48. #define A_CASE_NUMBERS        8
  49. #define A_CASE_STRINGS        9
  50. #define A_CASE_LABELS           10
  51. #define NUMAREAS           11
  52.  
  53. #define BREAK_ON_STACK        0x40000
  54. #define BREAK_FROM_CASE        0x80000
  55.  
  56. /* make shure that this struct has a size that is a power of two */
  57. struct case_heap_entry { int key; short addr; short line; };
  58. #define CASE_HEAP_ENTRY_ALIGN(offset) offset &= -sizeof(struct case_heap_entry)
  59.  
  60. static struct mem_block mem_block[NUMAREAS];
  61.  
  62. /*
  63.  * Some good macros to have.
  64.  */
  65.  
  66. #define BASIC_TYPE(e,t) ((e) == TYPE_ANY ||\
  67.              (e) == (t) ||\
  68.              (t) == TYPE_ANY)
  69.  
  70. #define TYPE(e,t) (BASIC_TYPE((e) & TYPE_MOD_MASK, (t) & TYPE_MOD_MASK) ||\
  71.            (((e) & TYPE_MOD_POINTER) && ((t) & TYPE_MOD_POINTER) &&\
  72.             BASIC_TYPE((e) & (TYPE_MOD_MASK & ~TYPE_MOD_POINTER),\
  73.                    (t) & (TYPE_MOD_MASK & ~TYPE_MOD_POINTER))))
  74.  
  75. #define FUNCTION(n) ((struct function *)mem_block[A_FUNCTIONS].block + (n))
  76. #define VARIABLE(n) ((struct variable *)mem_block[A_VARIABLES].block + (n))
  77.  
  78. #define align(x) (((x) + 3) & ~3)
  79.  
  80. /*
  81.  * If the type of the function is given, then strict types are
  82.  * checked and required.
  83.  */
  84. static int exact_types;
  85. extern int pragma_strict_types;    /* Maintained by lex.c */
  86. extern int pragma_save_types;    /* Also maintained by lex.c */
  87. int approved_object;        /* How I hate all these global variables */
  88.  
  89. extern int total_num_prog_blocks, total_prog_block_size;
  90.  
  91. extern int num_parse_error;
  92. extern int d_flag;
  93. static int heart_beat;        /* Number of the heart beat function */
  94.  
  95. static int current_break_address;
  96. static int current_continue_address;
  97. static int current_case_number_heap;
  98. static int current_case_string_heap;
  99. #define SOME_NUMERIC_CASE_LABELS 0x40000
  100. #define NO_STRING_CASE_LABELS    0x80000
  101. static int zero_case_label;
  102. static int current_type;
  103.  
  104. static int last_push_indexed;
  105. static int last_push_local;
  106. static int last_push_identifier;
  107.  
  108. /*
  109.  * There is always function starting at address 0, which will execute
  110.  * the initialization code. This code is spread all over the program,
  111.  * with jumps to next initializer. The next variable keeps track of
  112.  * the previous jump. After the last initializer, the jump will be changed
  113.  * into a return(0) statement instead.
  114.  *
  115.  * A function named '__INIT' will be defined, which will contain the
  116.  * initialization code. If there was no initialization code, then the
  117.  * function will not be defined. That is the usage of the
  118.  * first_last_initializer_end variable.
  119.  *
  120.  * When inheriting from another object, a call will automatically be made
  121.  * to call __INIT in that code from the current __INIT.
  122.  */
  123. static int last_initializer_end;
  124. static int first_last_initializer_end;
  125.  
  126. static struct program NULL_program; /* marion - clean neat empty struct */
  127.  
  128. void epilog();
  129. static int check_declared PROT((char *str));
  130. static void prolog();
  131. static char *get_two_types PROT((int type1, int type2));
  132. void free_all_local_names(),
  133.     add_local_name PROT((char *, int)), smart_log PROT((char *, int, char *));
  134. extern int yylex();
  135. extern char *findstring PROT((char *));
  136. static int verify_declared PROT((char *));
  137. static void copy_variables();
  138. static int copy_functions PROT((struct program *, int type));
  139. void type_error PROT((char *, int));
  140.  
  141. char *xalloc(), *string_copy();
  142.  
  143. extern int current_line;
  144. /*
  145.  * 'inherit_file' is used as a flag. If it is set to a string
  146.  * after yyparse(), this string should be loaded as an object,
  147.  * and the original object must be loaded again.
  148.  */
  149. extern char *current_file, *inherit_file;
  150.  
  151. /*
  152.  * The names and types of arguments and auto variables.
  153.  */
  154. char **local_names;
  155. unsigned short *type_of_locals;
  156. int current_number_of_locals = 0;
  157. int current_break_stack_need = 0  ,max_break_stack_need = 0;
  158.  
  159. /*
  160.  * The types of arguments when calling functions must be saved,
  161.  * to be used afterwards for checking. And because function calls
  162.  * can be done as an argument to a function calls,
  163.  * a stack of argument types is needed. This stack does not need to
  164.  * be freed between compilations, but will be reused.
  165.  */
  166. static struct mem_block type_of_arguments;
  167.  
  168. struct program *prog;    /* Is returned to the caller of yyparse */
  169.  
  170. void init_compiler(void)
  171. {
  172.     memset(&mem_block, 0, sizeof(struct mem_block) * NUMAREAS);
  173.     memset(&type_of_arguments, 0, sizeof(type_of_arguments));
  174. }
  175.  
  176. /*
  177.  * Compare two types, and return true if they are compatible.
  178.  */
  179. static int compatible_types(t1, t2)
  180.     int t1, t2;
  181. {
  182.     if (t1 == TYPE_UNKNOWN || t2 == TYPE_UNKNOWN)
  183.     return 0;
  184.     if (t1 == t2)
  185.     return 1;
  186.     if (t1 == TYPE_ANY || t2 == TYPE_ANY)
  187.     return 1;
  188.     if ((t1 & TYPE_MOD_POINTER) && (t2 & TYPE_MOD_POINTER)) {
  189.     if ((t1 & TYPE_MOD_MASK) == (TYPE_ANY|TYPE_MOD_POINTER) ||
  190.         (t2 & TYPE_MOD_MASK) == (TYPE_ANY|TYPE_MOD_POINTER))
  191.         return 1;
  192.     }
  193.     return 0;
  194. }
  195.  
  196. /*
  197.  * Add another argument type to the argument type stack
  198.  */
  199. INLINE
  200. static void add_arg_type(type)
  201.     unsigned short type;
  202. {
  203.     struct mem_block *mbp = &type_of_arguments;
  204.     while (mbp->current_size + sizeof type > mbp->max_size) {
  205.     mbp->max_size <<= 1;
  206.     mbp->block = xrealloc((char *)mbp->block, mbp->max_size);
  207.     }
  208.     memcpy(mbp->block + mbp->current_size, &type, sizeof type);
  209.     mbp->current_size += sizeof type;
  210. }
  211.  
  212. /*
  213.  * Pop the argument type stack 'n' elements.
  214.  */
  215. INLINE
  216. static void pop_arg_stack(n)
  217.     int n;
  218. {
  219.     type_of_arguments.current_size -= sizeof (unsigned short) * n;
  220. }
  221.  
  222. /*
  223.  * Get type of argument number 'arg', where there are
  224.  * 'n' arguments in total in this function call. Argument
  225.  * 0 is the first argument.
  226.  */
  227. INLINE
  228. int get_argument_type(arg, n)
  229.     int arg, n;
  230. {
  231.     return
  232.     ((unsigned short *)
  233.      (type_of_arguments.block + type_of_arguments.current_size))[arg - n];
  234. }
  235.  
  236. INLINE
  237. static void add_to_mem_block(n, data, size)
  238.     int n, size;
  239.     char *data;
  240. {
  241.     struct mem_block *mbp = &mem_block[n];
  242.     while (mbp->current_size + size > mbp->max_size) {
  243.     mbp->max_size <<= 1;
  244.     mbp->block = xrealloc((char *)mbp->block, mbp->max_size);
  245.     }
  246.     memcpy(mbp->block + mbp->current_size, data, size);
  247.     mbp->current_size += size;
  248. }
  249.  
  250. static void ins_byte(b)
  251.     char b;
  252. {
  253.     add_to_mem_block(A_PROGRAM, &b, 1);
  254. }
  255.  
  256. /*
  257.  * Store a 2 byte number. It is stored in such a way as to be sure
  258.  * that correct byte order is used, regardless of machine architecture.
  259.  * Also beware that some machines can't write a word to odd addresses.
  260.  */
  261. static void ins_short(l)
  262.     short l;
  263. {
  264.     add_to_mem_block(A_PROGRAM, (char *)&l + 0, 1);
  265.     add_to_mem_block(A_PROGRAM, (char *)&l + 1, 1);
  266. }
  267.  
  268. static void upd_short(offset, l)
  269.     int offset;
  270.     short l;
  271. {
  272.     mem_block[A_PROGRAM].block[offset + 0] = ((char *)&l)[0];
  273.     mem_block[A_PROGRAM].block[offset + 1] = ((char *)&l)[1];
  274. }
  275.  
  276. static short read_short(offset)
  277.     int offset;
  278. {
  279.     short l;
  280.  
  281.     ((char *)&l)[0] = mem_block[A_PROGRAM].block[offset + 0];
  282.     ((char *)&l)[1] = mem_block[A_PROGRAM].block[offset + 1];
  283.     return l;
  284. }
  285.  
  286. /*
  287.  * Store a 4 byte number. It is stored in such a way as to be sure
  288.  * that correct byte order is used, regardless of machine architecture.
  289.  */
  290. static void ins_long(l)
  291.     int l;
  292. {
  293.     add_to_mem_block(A_PROGRAM, (char *)&l+0, 1);
  294.     add_to_mem_block(A_PROGRAM, (char *)&l+1, 1);
  295.     add_to_mem_block(A_PROGRAM, (char *)&l+2, 1);
  296.     add_to_mem_block(A_PROGRAM, (char *)&l+3, 1);
  297. }
  298.  
  299. static void ins_f_byte(b)
  300.     unsigned int b;
  301. {
  302.     ins_byte((char)(b - F_OFFSET));
  303. }
  304.  
  305. /*
  306.  * Return the index of the function found, otherwise -1.
  307.  */
  308. static int defined_function(s, start)
  309.     char *s;
  310.     int start;
  311. {
  312.     int offset;
  313.     struct function *funp;
  314.     char *interned;
  315.  
  316.     if (interned = findstring(s))    /* Only search if amongst strings */
  317.     for (offset = start * sizeof (struct function);
  318.       offset < mem_block[A_FUNCTIONS].current_size;
  319.       offset += sizeof (struct function))
  320.     {
  321.         funp = (struct function *)&mem_block[A_FUNCTIONS].block[offset];
  322.         if (funp->flags & NAME_HIDDEN)
  323.         continue;
  324.         if (funp->name == interned)
  325.         return offset / sizeof (struct function);
  326.     }
  327.     return -1;
  328. }
  329.  
  330. /*
  331.  * A mechanism to remember addresses on a stack. The size of the stack is
  332.  * defined in config.h.
  333.  */
  334. static int comp_stackp;
  335. int *comp_stack;
  336.  
  337. static void push_address() {
  338.     if (comp_stackp >= COMPILER_STACK_SIZE) {
  339.     yyerror("Compiler stack overflow");
  340.     comp_stackp++;
  341.     return;
  342.     }
  343.     comp_stack[comp_stackp++] = mem_block[A_PROGRAM].current_size;
  344. }
  345.  
  346. static void push_explicit(address)
  347.     int address;
  348. {
  349.     if (comp_stackp >= COMPILER_STACK_SIZE) {
  350.     yyerror("Compiler stack overflow");
  351.     comp_stackp++;
  352.     return;
  353.     }
  354.     comp_stack[comp_stackp++] = address;
  355. }
  356.  
  357. static int pop_address() {
  358.     if (comp_stackp == 0)
  359.     fatal("Compiler stack underflow.\n");
  360.     if (comp_stackp > COMPILER_STACK_SIZE) {
  361.     --comp_stackp;
  362.     return 0;
  363.     }
  364.     return comp_stack[--comp_stackp];
  365. }
  366.  
  367. /*
  368.  * Patch a function definition of an inherited function, to what it really
  369.  * should be.
  370.  * The name of the function can be one of:
  371.  *    object::name
  372.  *    ::name
  373.  *    name
  374.  * Where 'object' is the name of the superclass.
  375.  */
  376. static void find_inherited(funp)
  377.     struct function *funp;
  378. {
  379.     int i;
  380.     struct inherit *ip;
  381.     int num_inherits, super_length;
  382.     char *real_name, *super_name = 0, *p;
  383.     char *interned;
  384.  
  385.     real_name = funp->name;
  386.     if (real_name[0] == ':')
  387.     real_name = real_name + 2;    /* There will be exactly two ':' */
  388.     else if (p = strchr(real_name, ':')) {
  389.     real_name = p+2;
  390.     super_name = funp->name;
  391.     super_length = real_name - super_name - 2;
  392.     }
  393.     num_inherits = mem_block[A_INHERITS].current_size /
  394.     sizeof (struct inherit);
  395.     ip = &((struct inherit *)mem_block[A_INHERITS].block)[num_inherits-1];
  396.     if (interned = findstring(real_name)) /* Only search if amongst strings */
  397.       for (; num_inherits > 0; ip--, num_inherits--) {
  398.     if (super_name) {
  399.         int l = strlen(ip->prog->name);    /* Including .c */
  400.         if (l - 2 < super_length)
  401.         continue;
  402.         if (strncmp(super_name, ip->prog->name + l - 2 - super_length,
  403.             super_length) != 0)
  404.         continue;
  405.     }
  406.     for (i=0; i < ip->prog->num_functions; i++) {
  407.         if (ip->prog->functions[i].flags & (NAME_UNDEFINED|NAME_HIDDEN))
  408.         continue;
  409.         if (ip->prog->functions[i].type & TYPE_MOD_PRIVATE)
  410.         continue;
  411.         if (ip->prog->functions[i].name != interned)
  412.         continue;
  413.         funp->offset = ip - (struct inherit *)mem_block[A_INHERITS].block;
  414.         funp->flags = ip->prog->functions[i].flags | NAME_INHERITED;
  415.         funp->num_local = ip->prog->functions[i].num_local;
  416.         funp->num_arg = ip->prog->functions[i].num_arg;
  417.         funp->type = ip->prog->functions[i].type;
  418.         funp->type |= funp->type & TYPE_MOD_PUBLIC ?
  419.         ip->type & ~TYPE_MOD_PRIVATE : ip->type;
  420.         funp->function_index_offset = i;
  421.         return;
  422.     }
  423.       }
  424.     return;
  425. }
  426.  
  427. void replace_function(num, name, num_arg, num_local, offset, flags, type)
  428. int num, num_arg, num_local, offset, flags, type;
  429. char *name;
  430. {
  431.     struct function *funp;
  432.  
  433.     funp = (struct function *)(mem_block[A_FUNCTIONS].block) + num;
  434.     if (!(funp->flags & NAME_UNDEFINED) &&
  435.     !(flags & NAME_PROTOTYPE) &&
  436.     !(funp->flags & NAME_INHERITED))
  437.     {
  438.     char buff[500];
  439.     sprintf(buff, "Redeclaration of function %s.", name);
  440.     yyerror(buff);
  441.     return;
  442.     }
  443.     /*
  444.      * It was either an undefined but used function, or an inherited
  445.      * function. In both cases, we now consider this to be THE new
  446.      * definition. It might also have been a prototype to an already
  447.      * defined function.
  448.      *
  449.      * Check arguments only when types are supposed to be tested,
  450.      * and if this function really has been defined already.
  451.      *
  452.      * 'nomask' functions may not be redefined.
  453.      */
  454.     if ((funp->type & TYPE_MOD_NO_MASK) &&
  455.     !(funp->flags & NAME_PROTOTYPE) &&
  456.     !(flags & NAME_PROTOTYPE))
  457.     {
  458.     char *p = (char *)alloca(80 + strlen(name));
  459.     sprintf(p, "Illegal to redefine 'nomask' function \"%s\"",name);
  460.     yyerror(p);
  461.     }
  462.     if (exact_types && funp->type != TYPE_UNKNOWN) {
  463.     int i;
  464.     if (funp->num_arg != num_arg && !(funp->type & TYPE_MOD_VARARGS))
  465.         yyerror("Incorrect number of arguments.");
  466.     else if (!(funp->flags & NAME_STRICT_TYPES))
  467.         yyerror("Called function not compiled with type testing.");
  468.     else {
  469.         /* Now check that argument types wasn't changed. */
  470.         for (i=0; i < num_arg; i++) {
  471.         }
  472.     }
  473.     }
  474.     /* If it was yet another prototype, then simply return. */
  475.     if (flags & NAME_PROTOTYPE)
  476.     return;
  477.     funp->num_arg = num_arg;
  478.     funp->num_local = num_local;
  479.     funp->flags = flags;
  480.     funp->offset = offset;
  481.     funp->function_index_offset = 0;
  482.     funp->type = type;
  483.     if (exact_types)
  484.     funp->flags |= NAME_STRICT_TYPES;
  485.     return;
  486. }
  487.  
  488. /*
  489.  * Define a new function. Note that this function is called at least twice
  490.  * for alll function definitions. First as a prototype, then as the real
  491.  * function. Thus, there are tests to avoid generating error messages more
  492.  * than once by looking at (flags & NAME_PROTOTYPE).
  493.  */
  494. static int define_new_function(name, num_arg, num_local, offset, flags, type)
  495.     char *name;
  496.     int num_arg, num_local;
  497.     int offset, flags, type;
  498. {
  499.     int num;
  500.     struct function fun;
  501.     unsigned short argument_start_index;
  502.  
  503.     num = defined_function(name, 0);
  504.     if (num >= 0) {
  505.     int save_num;
  506.  
  507.     /*
  508.      * The function was already defined. It may be one of several reasons:
  509.      *
  510.      * 1.    There has been a prototype.
  511.      * 2.    There was the same function defined by inheritance.
  512.      * 3.    This function has been called, but not yet defined.
  513.      * 4.    The function is doubly defined.
  514.      * 5.    A "late" prototype has been encountered.
  515.      */
  516.     do {
  517.         replace_function(num, name, num_arg, num_local, offset, flags,type);
  518.         save_num = num;
  519.         num = defined_function(name, num+1);
  520.     } while (num >= 0);
  521.     return save_num;
  522.     }
  523.     if (strcmp(name, "heart_beat") == 0)
  524.     heart_beat = mem_block[A_FUNCTIONS].current_size /
  525.         sizeof (struct function);
  526.     fun.name = make_shared_string(name);
  527.     fun.offset = offset;
  528.     fun.flags = flags;
  529.     fun.num_arg = num_arg;
  530.     fun.num_local = num_local;
  531.     fun.function_index_offset = 0;
  532.     fun.type = type;
  533.     if (exact_types)
  534.     fun.flags |= NAME_STRICT_TYPES;
  535.     num = mem_block[A_FUNCTIONS].current_size / sizeof fun;
  536.     /* Number of local variables will be updated later */
  537.     add_to_mem_block(A_FUNCTIONS, (char *)&fun, sizeof fun);
  538.  
  539.     if (exact_types == 0 || num_arg == 0) {
  540.     argument_start_index = INDEX_START_NONE;
  541.     } else {
  542.     int i;
  543.  
  544.     /*
  545.      * Save the start of argument types.
  546.      */
  547.     argument_start_index =
  548.         mem_block[A_ARGUMENT_TYPES].current_size /
  549.         sizeof (unsigned short);
  550.     for (i=0; i < num_arg; i++) {
  551.         add_to_mem_block(A_ARGUMENT_TYPES, &type_of_locals[i],
  552.                  sizeof type_of_locals[i]);
  553.     }
  554.     }
  555.     add_to_mem_block(A_ARGUMENT_INDEX, &argument_start_index,
  556.              sizeof argument_start_index);
  557.     return num;
  558. }
  559.  
  560. static void define_variable(name, type, flags)
  561.     char *name;
  562.     int type;
  563.     int flags;
  564. {
  565.     struct variable dummy;
  566.     int n;
  567.  
  568.     n = check_declared(name);
  569.     if (n != -1 && (VARIABLE(n)->type & TYPE_MOD_NO_MASK)) {
  570.     char *p = (char *)alloca(80 + strlen(name));
  571.     sprintf(p, "Illegal to redefine 'nomask' variable \"%s\"", name);
  572.     yyerror(p);
  573.     }
  574.     dummy.name = make_shared_string(name);
  575.     dummy.type = type;
  576.     dummy.flags = flags;
  577.     add_to_mem_block(A_VARIABLES, (char *)&dummy, sizeof dummy);
  578. }
  579.  
  580. short store_prog_string(str)
  581.     char *str;
  582. {
  583.     short i;
  584.     char **p;
  585.  
  586.     p = (char **) mem_block[A_STRINGS].block;
  587.     str = make_shared_string(str);
  588.     for (i=mem_block[A_STRINGS].current_size / sizeof str -1; i>=0; --i)
  589.     if (p[i] == str)  {
  590.         free_string(str); /* Needed as string is only free'ed once. */
  591.         return i;
  592.     }
  593.  
  594.     add_to_mem_block(A_STRINGS, &str, sizeof str);
  595.     return mem_block[A_STRINGS].current_size / sizeof str - 1;
  596. }
  597.  
  598. void add_to_case_heap(block_index,entry)
  599.     int block_index;
  600.     struct case_heap_entry *entry;
  601. {
  602.     char *heap_start;
  603.     int offset,parent;
  604.     int current_heap;
  605.  
  606.     if ( block_index == A_CASE_NUMBERS )
  607.         current_heap = current_case_number_heap;
  608.     else
  609.         current_heap = current_case_string_heap;
  610.     offset = mem_block[block_index].current_size - current_heap;
  611.     add_to_mem_block(block_index, (char*)entry, sizeof(*entry) );
  612.     heap_start = mem_block[block_index].block + current_heap;
  613.     for ( ; offset; offset = parent ) {
  614.         parent = ( offset - sizeof(struct case_heap_entry) ) >> 1 ;
  615.         CASE_HEAP_ENTRY_ALIGN(parent);
  616.         if ( ((struct case_heap_entry*)(heap_start+offset))->key <
  617.              ((struct case_heap_entry*)(heap_start+parent))->key )
  618.         {
  619.             *(struct case_heap_entry*)(heap_start+offset) =
  620.             *(struct case_heap_entry*)(heap_start+parent);
  621.             *(struct case_heap_entry*)(heap_start+parent) = *entry;
  622.         }
  623.     }
  624. }
  625.  
  626. /*
  627.  * Arrange a jump to the current position for the initialization code
  628.  * to continue.
  629.  */
  630. static void transfer_init_control() {
  631.     if (mem_block[A_PROGRAM].current_size - 2 == last_initializer_end)
  632.     mem_block[A_PROGRAM].current_size -= 3;
  633.     else {
  634.     /*
  635.      * Change the address of the last jump after the last
  636.      * initializer to this point.
  637.      */
  638.     upd_short(last_initializer_end,
  639.           mem_block[A_PROGRAM].current_size);
  640.     }
  641. }
  642.  
  643. void add_new_init_jump();
  644. %}
  645.  
  646. /*
  647.  * These values are used by the stack machine, and can not be directly
  648.  * called from LPC.
  649.  */
  650. %token F_JUMP F_JUMP_WHEN_ZERO F_JUMP_WHEN_NON_ZERO
  651. %token F_POP_VALUE F_DUP
  652. %token F_STORE F_CALL_FUNCTION_BY_ADDRESS
  653. %token F_PUSH_IDENTIFIER_LVALUE F_PUSH_LOCAL_VARIABLE_LVALUE
  654. %token F_PUSH_INDEXED_LVALUE F_INDIRECT F_INDEX
  655. %token F_CONST0 F_CONST1
  656.  
  657. /*
  658.  * These are the predefined functions that can be accessed from LPC.
  659.  */
  660.  
  661. %token F_IF F_IDENTIFIER F_LAND F_LOR F_STATUS
  662. %token F_RETURN F_STRING
  663. %token F_INC F_DEC
  664. %token F_POST_INC F_POST_DEC F_COMMA
  665. %token F_NUMBER F_ASSIGN F_INT F_ADD F_SUBTRACT F_MULTIPLY
  666. %token F_DIVIDE F_LT F_GT F_EQ F_GE F_LE
  667. %token F_NE
  668. %token F_ADD_EQ F_SUB_EQ F_DIV_EQ F_MULT_EQ
  669. %token F_NEGATE
  670. %token F_SUBSCRIPT F_WHILE F_BREAK
  671. %token F_DO F_FOR F_SWITCH
  672. %token F_SSCANF F_PARSE_COMMAND F_STRING_DECL F_LOCAL_NAME
  673. %token F_ELSE F_DESCRIBE
  674. %token F_CONTINUE
  675. %token F_MOD F_MOD_EQ F_INHERIT F_COLON_COLON
  676. %token F_STATIC
  677. %token F_ARROW F_AGGREGATE F_M_AGGREGATE
  678. %token F_COMPL F_AND F_AND_EQ F_OR F_OR_EQ F_XOR F_XOR_EQ
  679. %token F_LSH F_LSH_EQ F_RSH F_RSH_EQ
  680. %token F_CATCH
  681. %token F_OBJECT F_VOID F_MIXED F_PRIVATE F_NO_MASK F_NOT F_MAPPING
  682. %token F_PROTECTED F_PUBLIC
  683. %token F_VARARGS
  684.